home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: netcom.com!jodell
- From: jodell@netcom.com (Jake Odell)
- Subject: Re: Help !!!!! on 'strstr"
- Message-ID: <jodellDoF8tu.EAL@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- X-Newsreader: TIN [version 1.2 PL1]
- References: <314703FF.4045@msmail.st.stems.com> <DoE30t.G5u@iquest.net>
- Date: Sun, 17 Mar 1996 17:05:54 GMT
- Sender: jodell@netcom8.netcom.com
-
- Doug & Rose Miller (dlmiller@iquest.net) posted:
- # kim hai <Kim_Hai.Ng@msmail.st.stems.com> wrote:
- # +Help !!!!!
- # +
- # +Problem :
- # + I need to locate a string within another string, and the process
- # +must be case insensitive. As far as I know, strstr() only locates the
- # +exact match and is case sensitive.
- # + Does anyone konw of any functions that could allow me to locate
- # +substrings and is case insensitive ?
- # +
- # +Eg.
- # +case 1:
- # + string1 = "abc"
- # + string2 = "abcdef"
- # +case 2:
- # + string2 = "Abcdef"
- # +case 3:
- # + string3 = "aBcdef"
- # +case 4:
- # + string4 = "abCdef"
- # +.....
- # +....
- # +...
- # +
- # +Is taking care of all the combinations ( = 8) in string1 the only
- # +solution ? I'm working on Unix platform.
- # +
- # +Thankx
- # +
- # +<hai>
- # +
- # Use strupr() on both strings -- to insure they are both the same case
- # -- before using strstr(). Of course, strlwr() would work also.
-
- # Perhaps you should copy both strings to temporary areas and use
- # strupr() on the temps, because it does not merely return the
- # case-shifted string, it actually case-shifts the original.
-
-
- Several others suggested this or similar approaches; I don't think this
- is a good technique for a general purpose solution, as you shouldn't
- modify the input strings, nor should there be length limits on them.
- --
- jake@pantheon.us.com jodell@netcom.com
-